class Tip {
	constructor(viewer) {
		this._viewer = viewer;
		this._frameDiv=viewer.cesiumWidget.container;
		this._isInit=false;
		this.init();
	}
	init() {
		var _self = this;
	    if (_self._isInit) { return; }
	    var div = document.createElement('DIV');
	    div.className = "CEarth-smallTooltip right";
	
	    var arrow = document.createElement('DIV');
	    arrow.className = "vfg-draw-tooltip-arrow";
	    div.appendChild(arrow);
	
	    var title = document.createElement('DIV');
	    title.className = "vfg-draw-tooltip-inner";
	    div.appendChild(title);
	    this._div = div;
	    this._title = title;
	    _self._frameDiv.appendChild(div);
	    _self._isInit = true;
	}
	setVisible(visible) {
		var _self = this;
	    if (!_self._isInit) { return; }
	    _self._div.style.display = visible ? 'block' : 'none';
	}
	showAt(position, message) {
		var _self = this;
	    if (!_self._isInit) { return; }
	    if (position && message) {
	    	_self.setVisible(true);
	    	_self._title.innerHTML = message;
	    	_self._div.style.position = "absolute"
	    	_self._div.style.left = position.x + 20 + "px";
	    	_self._div.style.top = (position.y - this._div.clientHeight/2) + "px";
	    }
	}
	destroy() {
		var _self = this;
		if( _self._div){
			 _self._frameDiv.removeChild( _self._div);
		}
		if( _self._title){
			 _self._frameDiv.removeChild( _self._title);
		}
		return Cesium.destroyObject(this);
	}
}
export {
	Tip
}